package com.ohuang.hook

import android.os.Bundle
import android.util.Log
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.ohuang.hook.http.testApi
import com.ohuang.kthttp.call.getResult
import com.ohuang.kthttp.call.getResultSafe
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
    val tv_main:TextView by lazy {
        findViewById<TextView>(R.id.tv_main)
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        lifecycleScope.launch {
            val gameInfo =testApi.getGameInfo(context = this@MainActivity).getResult()
            tv_main.text=gameInfo
        }
    }
}